/**
 * @file   singleton.h
 * @Author Alexandre Chassany (alexandre.chassany@gmail.com)
 * @date   February 2011
 * @brief  singleton definitions
 *
 * Poum-tchak is a free sound manipulation and synthesis, 
 * real-time and interactive music-clip rendering.
 *
 * Copyright (C) 2011  Chassany Alexandre and Gonzalez Antoine.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * he Free Software Foundation, either version 3 of the License, or
 * at your option) any later version.
 *
 * is program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef _ELIXIR_SINGLETON_H_
#define _ELIXIR_SINGLETON_H_

#include <core/noncopyable.h>

namespace Elixir
{
  
  /**
   *@class Singleton
   *@brief Meyers Singleton template class
   *@note This class is not thread safe !
   *@note This class can be used in two different ways:
   *  - First by inheritance like this => MyClass : Singleton<MyClass>.
   *  - Or as a template specification Singleton<MyClass>::Instance().
   * Use the first version when you want to ensure that only one instance
   * of your class will be created during the execution of your program.
   * Use the second version when you want to use a static instance of a 
   * class that can be instanciate anywhere in your program
   */
  
  template<class T> 
  class Singleton : public NonCopyable
  {
  public:
	static T* Instance()
	{
	  static T inst;
	  return &inst;
	}
	
  protected:
	Singleton(){};
	virtual ~Singleton(){};
  };
}
#endif // SINGLETON_H
